package com.example.service;

import com.example.entity.MapProgress;
import com.example.mapper.MapProgressMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*用户进度业务处理
 */
@Service
public class MapProgressService {

    @Resource
    private MapProgressMapper mapProgressMapper;

    public void add(MapProgress mapProgress) {
        mapProgressMapper.insert(mapProgress);
    }

    public void deleteById(Integer id) {
        mapProgressMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(MapProgress mapProgress) {
        mapProgressMapper.updateById(mapProgress);
    }

    public MapProgress selectById(Integer id) {
        return mapProgressMapper.selectById(id);
    }

    public List<MapProgress> selectAll(MapProgress mapProgress) {
        return mapProgressMapper.selectAll(mapProgress);
    }

    public PageInfo<MapProgress> selectPage(MapProgress mapProgress, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MapProgress> userProgressList = mapProgressMapper.selectAll(mapProgress);
        return PageInfo.of(userProgressList);
    }
}
